import type { UploadFile, UploadProps } from 'ant-design-vue'
import { isNil } from 'lodash-es'
import { Mode } from '@/core/interfaces/common'
import type { Creative } from '@/core/interfaces/promotion'
import type { PlatformEnum } from '@/core/enums/platform'

export interface GoodsFields {
  id?: number
  closable?: boolean
  orderWordId: Creative['orderWordId']
  name: string
  key: number
  title: string
  pictureName: string
  pictureURL: string
  imageContent: string
  info: string
  fileList: UploadProps['fileList']
  imageId?: string
  creativeGroupId?: number
  creativeGroupName?: string
  cropper: {
    show: boolean
    file?: UploadFile | File
  }
}

export interface PromotionFields {
  id?: number
  creativeId?: number
  groupId?: number
  destinationUrl: string
  title: string
  content: string
  pcGoods: GoodsFields[]
  wapGoods: GoodsFields[]

  details?: string
  feature?: string
  deviceName?: string
  service?: string
}

export interface TargetKeyword {
  word: string
  orderWordId: Creative['orderWordId']
  mode: Mode
  campaignId: Creative['campaignId']
  clientType: PlatformEnum
  groupId: PromotionFields['groupId']
  creativeId: PromotionFields['creativeId']
  id: Creative['id']
  pcGoods: Creative['pcGoods']
  wapGoods: Creative['wapGoods']
}

export const calMode = (id?: number) => {
  return isNil(id) || id === 0 ? Mode.create : Mode.edit
}

export interface ComposableFields {
  result: string[]
  combinedWordNum: number
}

export interface ComposableState extends ComposableFields {
  word: string
  keyword: string[]
  areas: string[]
  suffix: string[]
}

export interface CBComposableState {
  result: valueType[]
  combinedWordNum: number
  word: string
  keyword: string[]
  areas: string[]
  suffix: string[]
}

export interface Options {
  label: string
  type: PlatformEnum
  name: string
  value: string
}

export interface valueType {
  type: PlatformEnum
  name: string
}

export enum GiftKindEnum {
  Gift = 1,
  Composable = 2,
  Edit = 3
}

export interface CbNumType {
  pcNumber?: number
  wapNumber?: number
  orderId?: number
}

export enum typeEnum {
  PC = 0,
  WAP = 1
}
